package com.cmcc.groupcontacts.base;

import android.app.Activity;
import android.view.KeyEvent;

/**
 * Created with IntelliJ IDEA.
 * User: zhyy
 * Date: 12-5-3
 * Time: 下午8:47
 */
public class BaseActivity extends Activity {


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        /*
        if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
            {
                AlertDialog dialog = new AlertDialog.Builder(this)
                        .setTitle(getString(R.string.exit_app_dialog_title))
                        .setMessage(getString(R.string.exit_app_dialog_content))
                        .setPositiveButton(getString(R.string.button_ok),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialoginterface, int i) {
                                        //按钮事件
                                        finish();
                                    }
                                })
                        .setNegativeButton(getString(R.string.button_cancel),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialoginterface, int i) {
                                        //按钮事件

                                    }
                                }).create();
                dialog.show();
                return true;
            }
        }
        */
        if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
            finish();
            return true;
        }
        return  super.onKeyDown(keyCode, event);

    }

    @Override
    public void onBackPressed() {
        finish();
        super.onBackPressed();
    }
}
